<?php
class MembersController extends CController {
	public function actionIndex() {
		$this->actionLists ();
	}
	public function actionLists() {
		$smarty = Yii::app ()->smarty;
		$criteria = array (
			
			'criteria' => array (
				
				'condition' => "state>0", 
				'with' => array (
					
					'meminfo' 
				) 
			) 
		);
		$showpage = "/tpl/default/showPage";
		$itemview = '/tpl/default/members/listpage';
		$pages = CommonFunc::yiiPage ( $this, "Members", 1, $showpage, $itemview, $criteria );
		$smarty->assign ( "pages", $pages );
		$smarty->assign ( "body", "members/lists" );
		$smarty->display ( "layouts.html" );
	}
	public function actionSearch() {
		$smarty = Yii::app ()->smarty;
		$ret = "";
		$smarty->assign ( "ret", $ret );
		$smarty->assign ( "body", "members/search" );
		$smarty->display ( "layouts.html" );
	}
	public function actionShowEdit() {
		$smarty = Yii::app ()->smarty;
		$id = addslashes ( $_GET ['id'] );
		$member = new Members ( );
		$ret = $member->getMembersById ( $id );
		$smarty->assign ( "ret", $ret );
		$smarty->display ( 'members/updateMembers.html' );
	}
	public function actionEdit() {
		if (isset ( $_POST ) && ! empty ( $_POST )) {
			$member = new Members ( );
			foreach ( $_POST as $v ) {
				$id = addslashes ( $_POST ['id'] );
				$array ['nickname'] = addslashes ( $_POST ['nickname'] );
				$array ['level'] = addslashes ( $_POST ['level'] );
				$array ['scores'] = addslashes ( $_POST ['scores'] );
				$array ['email'] = addslashes ( $_POST ['email'] );
				$passport = addslashes ( $_POST ['password'] );
				if (! empty ( $passport )) {
					$array ['password'] = md5 ( $passport );
				}
			}
			$ret = $member->updateByPk ( $id, $array );
			echo CommonFunc::AjaxCallbackMessage ( '200', $id, '', 'forward', 'http://www.baidu.com' );
		}
	}
	public function actionBanned() {
		$id = addslashes ( $_GET ['id'] );
		$state = addslashes ( $_GET ['state'] );
		$member = new Members ( );
		$ret = $member->updateByPk ( $id, array (
			
			"state" => $state 
		) );
		$this->actionLists ();
	}
	public function actionDel() {
		$id = addslashes ( $_GET ['id'] );
		$member = new Members ( );
		$ret = $member->updateByPk ( $id, array (
			
			"state" => 0 
		) );
		$this->actionLists ();
	}
}
?>